package cn.hfatec.shms.listener;

import cn.hfatec.shms.cache.CodeInfoCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 *
 * 应用初始化时，初始数据缓存
 *
 * @author: panwb
 *
 * Date: 2015/11/10
 * Time: 10:43
 */
public class InitDataListener implements InitializingBean, ApplicationContextAware {

    private Logger logger = LoggerFactory.getLogger(InitDataListener.class);

    private ApplicationContext applicationContext;


    @Override
    public void afterPropertiesSet() throws Exception {
        logger.info("初始化代码缓存数据");
        new CodeInfoCache(applicationContext).init();
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
